#include<bits/stdc++.h>
using namespace std;
#define int long long int
void Solve(){
int n;
cin>>n;
vector<pair<int,int>> arr(n),brr(n);
vector<int> ans(n,0);
for(int i=0;i<n;i++){
cin>>arr[i].first;
arr[i].second=i;
}
for(int i=0;i<n;i++){
cin>>brr[i].first;
brr[i].second=i;
}
sort(arr.begin(),arr.end());
sort(brr.begin(),brr.end());
int i=n-1;
set<int> st;
for(i=n-1;i>=0;i--){
st.insert(arr[i].second);
st.insert(brr[i].second);
if(st.size()==(n-i))break;
}
for(int j=i;j<n;j++)ans[arr[j].second]=1;
for(auto i:ans)cout<<i;
cout<<endl;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int T=1;
cin>>T;
while(T--){
Solve();
}
return 0;
}
766A - Mahmoud and Longest Uncommon Subsequence | 701B - Cells Not Under Attack |
702A - Maximum Increase | 1656D - K-good |
1426A - Floor Number | 876A - Trip For Meal |
1326B - Maximums | 1635C - Differential Sorting |
961A - Tetris | 1635B - Avoid Local Maximums |
20A - BerOS file system | 1637A - Sorting Parts |
509A - Maximum in Table | 1647C - Madoka and Childish Pranks |
689B - Mike and Shortcuts | 379B - New Year Present |
1498A - GCD Sum | 1277C - As Simple as One and Two |
1301A - Three Strings | 460A - Vasya and Socks |
1624C - Division by Two and Permutation | 1288A - Deadline |
1617A - Forbidden Subsequence | 914A - Perfect Squares |
873D - Merge Sort | 1251A - Broken Keyboard |
463B - Caisa and Pylons | 584A - Olesya and Rodion |
799A - Carrot Cakes | 1569B - Chess Tournament |